====== JavaScript Library SoSciTools ======

SoSci Survey automatically embeds a JavaScript library ''SoSciTools'' in the questionnaire. This can be used in [[:en:create:javascript|JavaScripts]] within the questionnaire.

===== SoSciTools =====

The following static methods are available through SoSciTools:

==== Questionnaire Elements ====

  * ''SoSciTools.getForm()'' -- Returns the HTML form element ''<form>'' of the questionnaire.
  * ''SoSciTools.disableInputs()'' -- Deactivates all input and selection fields on the current questionnaire page (e.g. to display questions again without the participant changing anything, see also [[:en:create:functions:answers]])
  * ''SoSciTools.disableInputs2()'' -- Replaces all input and selection fields with graphics or text elements.

  * ''SoSciTools.questionnaire'' -- instance of ''[[#soscitoolsquestionnaire|SoSciTools.Questionnaire]]'' to control the questionnaire page
  * ''SoSciTools.progress'' -- Instance of ''[[#soscitoolsprogress|SoSciTools.Progress]]'' to control the progress bar.


==== Questionnaire Control ====

  * ''SoSciTools.submitPage()'' -- Transmit the responses of the current page, as if the Next button was pressed.

==== Buttons in Questionnaires ====

  * ''SoSciTools.submitButtonsHide()'' -- Hide next and back button
  * ''SoSciTools.submitButtonsDisplay()'' -- Show next and back button
  * ''[[:en:create:soscitools:showbuttons|SoSciTools.showButtons()]]'' --Display of Next and Back button or other buttons (language switcher, cancel interview, interrupt interview) control
  * ''[[:en:create:soscitools:submitbuttonenable|SoSciTools.submitButtonEnable()]]'' -- Switch the Next button active or inactive (disabled)

==== General Help Functions ====

  * ''[[:en:create:soscitools:attachevent|SoSciTools.attachEvent()]]'' -- Assigns a function to one or more JavaScript events (cross-browser)
  * ''[[:en:create:soscitools:attacheventtoform|SoSciTools.attachEventToForm()]]'' -- Assigns a function to any change within the questionnaire page (cross-browser)
  * ''[[:en:create:soscitools:detachevent|SoSciTools.detachEvent()]]'' -- Detaches a previously assigned function from a JavaScript event (cross-browser).
  * ''[[:en:create:soscitools:dispatchevent|SoSciTools.dispatchEvent()]]'' -- Triggers a JavaScript event (cross-browser)
  * ''[[:en:create:soscitools:getsender|SoSciTools.getSender()]]'' -- Determines the source object of a JavaScript event (cross-browser).
  * ''[[:en:create:soscitools:inarray|SoSciTools.inArray()]]'' -- Checks if an element is contained in an array (cross-browser)
  * ''[[:en:create:soscitools:recordtime|SoSciTools.recordTime()]]'' -- records the processing time in an internal variable.


===== SoSciTools.Questionnaire =====

The variable ''SoSciTools.questionnaire'' hosts an object of the class ''SoSciTools.Questionnaire''. 
The object supports the following methods:

The variable ''SoSciTools.questionnaire'' hosts an object of the class ''SoSciTools.Questionnaire''

  * ''[[:en:create:soscitools:questionnaire:attachcheck|attachCheck()]]'' -- Registers a function to check the input. The function is called when the participant uses the Next button.
  * ''submit()'' -- Transmit the responses of the current page, as if the Next button was pressed.

===== SoSciTools.Progress =====

The variable ''SoSciTools.progress'' contains an object of the class ''SoSciTools.Progress'' and supports the following methods:

  * ''[[:en:create:soscitools:progress:addeventlistener|addEventListener()]]'' -- Registers a function for the events '''present''' or '''change'''.
  * ''[[:en:create:soscitools:progress:set|set()]]'' -- Changes the displayed percentage value. Unlike the PHP function ''[[:en:create:functions:option|option('progress', ...)]]'', this does not affect the percentage value displayed on the following page.
